package com.lei2j.command;

import org.junit.Test;

public class CommandTest {

	@Test
	public void test1() {
		GarageDoor garageDoor = new GarageDoor();
		Command command = new GarageDoorOpenCommand(garageDoor);
		Control control = new Control(command);
		control.buttonPressed();
		control.setCommand(new GarageDoorCloseCommand(garageDoor));
		control.buttonPressed();
	}
	
	@Test
	public void test2() {
		RemoteControl control = new RemoteControl();
		NoCommand noCommand = new NoCommand();
		Light light = new Light("卧室灯");
		Light light2 = new Light("客厅灯");
		Stereo stereo = new Stereo();
		LightOffCommand lightOffCommand = new LightOffCommand(light2);
		LightOnCommand lightOnCommand = new LightOnCommand(light);
		StereoOnWithCDCommand stereoOnWithCDCommand = new StereoOnWithCDCommand(stereo);
		control.setCommand(0, lightOnCommand, noCommand);
		control.setCommand(1, noCommand, lightOffCommand);
		control.setCommand(2, stereoOnWithCDCommand, noCommand);
		control.onButtonWasPushed(0);
		control.offButtonWasPushed(0);
		control.onButtonWasPushed(1);
		control.offButtonWasPushed(1);
		control.onButtonWasPushed(2);
//		control.offButtonWasPushed(2);
		control.undoButtonCommand();
	}
}
